package test;
import java.io.File;
import java.io.FileReader;
import org.junit.Test;

import parser.MiniP;
import parser.Procedure;
import parser.Start;


public class MiniPInterpeter extends TestCaseOutput{
	private final static String DATA = "data/";
    private final static String RESULT = "result/";
    private final static String FILE_EXTENSION = ".calc";
    private final static String RESULT_EXTENSION = ".res";
    
    private void assertCorrectOutput(String testName) {
        String fullName = testName + FILE_EXTENSION;
        execute(DATA + fullName);
        assertOutput(new File(RESULT + fullName + RESULT_EXTENSION));
    }

	@Test
	public void test() {
		assertCorrectOutput("test");
	}
	
	@Test
	public void test2() {
		assertCorrectOutput("test");
	}
	
	@Test
	public void test3() {
		assertCorrectOutput("test");
	}
	
	@Test
	public void test4() {
		assertCorrectOutput("test");
	}
	
	private static void execute(String arg) {
        try {
            MiniP parser = new MiniP(new FileReader(arg));
            Start start = parser.start();
            start.execute();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    }
	
	public static void main(String[] args) {
        execute(args[0]);
    }

}
